<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">账号管理</a>
            <a><cite>投放主体管理</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">选择公司：</label>
                    <div id="pMenu2" style="width:250px;flex:1"></div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">主体名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="subject" placeholder="请输入主体名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="official_accounts" lay-filter="official_accounts"></table>
    </div>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="add">新增</button>
        </div>
    </script>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    </script>
    <script>
        let params = {
            elem: '#official_accounts'
            , toolbar: '#toolbarDemo'
            , url: '/admin/subject/list' //数据接口
            , id: 'official_accounts'
            , page:true
            , limit:15
            , cols: [[ //表头
                { field: 'id', title: 'ID', width: 80, sort: true,align:'center' }
                , { field: 'company_name', title: '所属公司名称',align:'center' }
                , { field: 'media', title: '投放渠道',align:'center' }
                , { field: 'subject', title: '主体名称',align:'center' }
                , { field: 'rebate', title: '返点（%）',align:'center' }
                , { field: 'created_at', title: '添加时间',align:'center' }
                , { toolbar: '#tbBar', title: '操作', width: 150,align:'center' }
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('toolbar(official_accounts)', function (obj) {
                var event = obj.event;
                if (event === 'add') {
                    x_admin_show('添加主体', './info.html', 650, 600);
                }
            });
            table.on('tool(official_accounts)', function (obj) {
                var event = obj.event;
                if (event === 'del') {
                    // DeleteAjax('/admin/officialAccounts/delete',{ id: obj.data.id },'official_accounts')
                } else if (event === 'edit') {
                    x_admin_show('编辑主体', `./info.html?id=${obj.data.id}`, 650, 600);
                }
            });

        });
        let selectParams2 = {
            url: '/admin/company/select?type=1',
            selected: [],
            tips: '选择公司',
            name: 'company_id',
            field_id: 'id',
            field_Name: 'name',
            elem: '#pMenu2'
        }
        selectN(selectParams2)

    </script>
</body>

</html>